Q1]: Number of Attacks per year

q1_plot = ggplot(q1, aes(x=iyear, y=yearwise_attacks)) +
  geom_area(stat = "Identity",color = "darkorange3",size=0.5,fill="blue4")+
  geom_point(color="grey50",size=1.5)+labs(title = "No. of Attacks per Year", x= "Year" ,
                       y="Year Wise Attacks")
ggplotly(q1_plot)
19701980199020002010010002000300040005000
No. of Attacks per YearYearYear Wise Attacks

Q2]: Number of bombing per year

q2_plot = ggplot(q2, aes(x=iyear, y=yearwise_bombing)) +
  geom_area(stat = "Identity",color = "darkorange3",size=0.5,fill="chocolate2")+
  geom_point(color="grey50",size=1.5)+labs(title = "No. of Bombing per Year", x= "Year" ,
                       y="Year Wise Bombings")
ggplotly(q2_plot)

197019801990200020100250050007500
No. of Bombing per YearYearYear Wise Bombings
# Comparison between q1,q2

qn = merge(q1,q2, by = "iyear", all = T)
qn_plot = ggplot(qn, aes(iyear))+geom_line(aes(y=yearwise_attacks, col="No Of Attacks"),size=0.8)+geom_line(aes(y=yearwise_bombing, col="No Of Bombings"),size=0.8)+
  geom_point(aes(y=yearwise_attacks),col="blue",size=0.8)+
  geom_point(aes(y=yearwise_bombing),col="blue",size=0.8)+labs(title = "No. of Attacks and Bombings per Year", x= "Year" ,
                       y="Year Wise Attacks")
ggplotly(qn_plot)
197019801990200020100250050007500
No Of AttacksNo Of BombingsNo. of Attacks and Bombings per YearYearYear Wise Attackscolour

Q3]: Terrorist attacks region wise per year

q3_plot = ggplot(q3,aes(x=iyear,y=Tot_Terr_Att))+
  geom_area(aes(fill = region_txt),col='Black')+
  facet_wrap(~region_txt, scales="free",ncol=3)+
  geom_point(col="black",size=0.8)+
  theme(legend.position =' ')+
  theme(legend.title = element_blank())+
  labs(subtitle='From 1970 to 2015',y='No Of Attacks', x='Year', title='Terrorist attacks region wise per year',caption ='www.GTD.com')
q3_plot

Q4]: Top 5 type of terror attacks per region

## Selecting by Totall_Attacks
q4_plot = ggplot(q4, aes(x=attacktype1_txt,y=Totall_Attacks))+geom_bar(stat = "Identity",width = .5, aes(fill =attacktype1_txt))+
  theme(legend.title = element_blank())+
  theme(legend.position = "bottom", legend.key.width = unit(.2, "cm"))+
  labs(subtitle='From 1970 to 2015',y='No Of Attacks', x='Region', title='Top 5 type of terror attacks per region',caption ='www.GTD.com')+
  theme_bw() + facet_wrap(~region_txt, scales="free",ncol=3)+
  theme(legend.title = element_blank())+
  theme(axis.title.x=element_blank(), axis.text.x=element_blank(),axis.ticks.x=element_blank())
q4_plot

## # A tibble: 10 x 2
##    targtype1_txt                  Total_cas
##    <chr>                              <dbl>
##  1 Private Citizens & Property       254205
##  2 Military                          146440
##  3 Police                            100596
##  4 Business                           68728
##  5 Government (General)               61279
##  6 Transportation                     53030
##  7 Religious Figures/Institutions     33922
##  8 Terrorists/Non-State Militia       13977
##  9 Educational Institution            12688
## 10 Government (Diplomatic)            11803
q5_plot = ggplot(q5, aes(x=reorder(targtype1_txt,-Total_cas), y=Total_cas))+
  geom_bar(stat = "Identity",aes(fill=targtype1_txt),width = 0.9)+
  geom_text(aes(label=`Total_cas`),position = position_stack(vjust=1))+
  theme(legend.position = "bottom", legend.key.width = unit(2, "cm"))+
  theme_bw()+
  theme(legend.title = element_blank())+
  scale_y_continuous(breaks = seq(10500,255000,50000))+
  theme(axis.text.x=element_blank(),axis.ticks.x = element_blank())+
  labs(subtitle="Global Terrorism Data", y="Total casualities ", x="Types of Targets", title="[5]:Heaviest heat target types(based on wounded and killed)")



q5_plot

Q6]: Terrorist attack in India and Pakistan in last 45 years

q6_plot =ggplot(q6,aes(x=iyear,y=Total_terr_att))+
  geom_bar(stat = 'identity',aes(fill=country_txt,width = .5))+
  theme(legend.title = element_blank())+
  theme(legend.position = "bottom", legend.key.width = unit(.5, "cm"))+
  labs(subtitle='From 1970 to 2015',y='No Of Attacks', x='Year', title='Terrorist attack in India and Pakistan in last 45 years',caption ='www.GTD.com')

ggplotly(q6_plot)

197019801990200020100100020003000
IndiaPakistanTerrorist attack in India and Pakistan in last 45 yearsYearNo Of Attacks
#Q7]: Terror attack in United States vs Russian Federation/USSR in last 45 years

q7_plot = ggplot(q7,aes(x=iyear,y=Tot_att))+
  geom_bar(stat = 'identity',aes(fill=country_txt,width = .5))+
  theme_bw() +
  labs(subtitle='From 1970 to 2015',y='No Of Attacks', x='Years', title='Terror attack in United States vs Russian Federation/USSR in last 45 years',caption ='www.GTD.com')
ggplotly(q7_plot)
197019801990200020100100200300
RussiaUnited StatesTerror attack in United States vs Russian Federation/USSR in last 45 yearsYearsNo Of Attackscountry_txt

Q8]: Where are there the most casualties?

Grouping by countrywise

q8a_plot = ggplot(q8, aes(x=reorder(country_txt,-Total_casualties), y=Total_casualties))+
  geom_bar(stat = "Identity", aes(fill=country_txt),width = .40)+
  theme(axis.text.x = element_text(angle = 45),axis.ticks = element_blank())+
  theme(legend.position = "bottom",legend.title = element_blank())+
  theme(legend.text = element_text(colour = 'black', 
                                   size = 8,face='bold'))+
  labs(subtitle='From 1970 to 2015',y='No Of Casualities', x='Countries', title='Where are there the most casualties',caption ='www.GTD.com')
ggplotly(q8a_plot)
IraqPakistanAfghanistanIndiaSri LankaNigeriaColombiaPhilippinesAlgeriaSyria050000100000150000
AfghanistanAlgeriaColombiaIndiaIraqNigeriaPakistanPhilippinesSri LankaSyriaWhere are there the most casualtiesCountriesNo Of Casualities

grouping by Targetwise

q8b_plot = ggplot(q8b, aes(x=reorder(targtype1_txt,-Total_casualtis), y=Total_casualtis))+
  geom_bar(stat = "Identity", aes(fill=targtype1_txt))+theme_bw()+
  theme(axis.text.x = element_blank(),axis.ticks = element_blank())+
  theme(legend.position = "",legend.title = element_blank())+
  theme(legend.text = element_text(colour = 'black', size = 8,face = 'bold'))+
  labs(title='Where are there the most casualties',subtitle='From 1970 to 2015',y='No Of Casualities', x='Types of Target',caption ='www.GTD.com')+scale_y_continuous(labels = scales::comma)

ggplotly(q8b_plot)
0100,000200,000
Airports & AircraftBusinessEducational InstitutionGovernment (Diplomatic)Government (General)Journalists & MediaMilitaryPolicePrivate Citizens & PropertyReligious Figures/InstitutionsTerrorists/Non-State MilitiaTouristsTransportationUtilitiesViolent Political PartyWhere are there the most casualtiesTypes of TargetNo Of Casualities

Q9]: How have casualties evolved throughout the years?

q9_plot = ggplot(q9,aes(x=iyear))+
  geom_line(aes(y=total_kill),col='red',size=1)+
  geom_line(aes(y=total_wound),col='blue',size=1)+
  labs(subtitle='Kills=Red  Wounded=Blue',y='No Of Casualities', x='Year', title='How have casualties evolved throughout the years',caption ='www.GTD.com')+
  theme_bw()+  
  theme(axis.text.x = element_text())+
  theme(legend.position = " ")+
  scale_x_continuous(breaks = seq(1970,2015,5))+
  scale_y_continuous(breaks = seq(80,44000,5000))+
  geom_point(aes(y=q9$total_kill),col='Black',size=1)+
  geom_point(aes(y=q9$total_wound),col='black',size=1)+
  theme(legend.text = element_text(colour = 'black', size = 8,face = 'bold'))
ggplotly(q9_plot)
197019751980198519901995200020052010201580508010080150802008025080300803508040080
How have casualties evolved throughout the yearsYearNo Of Casualities

Q10]: What are the casualties by weapon type?

q10_plot = ggplot(q10, aes(x=reorder(weaptype1_txt,-Total_casualtes), y=Total_casualtes))+
  geom_bar(stat = "Identity", aes(fill=weaptype1_txt))+theme_bw()+
  theme(axis.text.x = element_blank(),axis.ticks.x = element_blank())+
  labs(subtitle="Global Terrorism Data", 
       y="Total Number of Casualties", x="Types of Weapons", title="10]:Total casualties by Weapon Type")+
  scale_y_continuous(labels = scales::comma)


ggplotly(q10_plot)
0100,000200,000300,000400,000500,000
BiologicalChemicalExplosives/Bombs/DynamiteFirearmsIncendiaryMeleeVehicles10]:Total casualties by Weapon TypeTypes of WeaponsTotal Number of Casualtiesweaptype1_txt

Q11]: Are certain nationalities more targeted? If yes, which one?

q11_plot = ggplot(q11, aes(x=reorder(country_txt,-Total_attacks), y=Total_attacks))+
  geom_bar(stat = "Identity", aes(fill=country_txt))+theme_bw()+
  theme(axis.text.x = element_blank(),axis.ticks.x = element_blank())+
  labs(subtitle="Global Terrorism Data", 
       y="Total Number of Attacks", x="Countries", title="11]:Targeted Nationalities")


ggplotly(q11_plot)
050001000015000
AfghanistanColombiaIndiaIraqNigeriaPakistanPeruPhilippinesSomaliaSpainSri LankaThailandTurkeyUnited KingdomEl Salvador11]:Targeted NationalitiesCountriesTotal Number of Attackscountry_txt

Q12]: Are some countries better at defending themselves against terrorist attacks? If yes, which is the safest country to live

Less casualtywise

q12_plot = ggplot(q12, aes(x=country_txt))+
  geom_bar()+theme_light()+
  labs(subtitle="Global Terrorism Data", x="Countries",y="Count", title="12]:Safest Countries")+theme(axis.text.x = element_text(angle = 45))

ggplotly(q12_plot)
Antigua and BarbudaVanuatuWallis and FutunaIcelandAndorraFalkland IslandsNew HebridesSeychellesCorsica0.000.250.500.751.00
12]:Safest CountriesCountriesCount

Success ratewise

q12b_plot = ggplot(q12b, aes(x=reorder(country_txt,ratio), y=ratio))+
  geom_segment(aes(x=country_txt,y=0,xend=country_txt,yend = ratio),color="blue")+geom_point()+
  theme_bw()+theme(axis.text.x = element_text(angle = 45),axis.ticks.x = element_blank())+
  labs(subtitle="Global Terrorism Data", 
       y="Ratio of defends per attack", x="Countries", title="12]:Safest Countries")

ggplotly(q12b_plot)
BahamasIrelandNew ZealandTurkmenistanBruneiDominicaGambiaGibraltarMauritiusVatican City0.000.250.500.751.00
12]:Safest CountriesCountriesRatio of defends per attack